package com.konne.nightmare.FastPublicOpinion.mvp.model.impl;


import com.konne.nightmare.FastPublicOpinion.base.OnLoadDataListener;
import com.konne.nightmare.FastPublicOpinion.bean.HomeBean;
import com.konne.nightmare.FastPublicOpinion.http.BaseObserver;
import com.konne.nightmare.FastPublicOpinion.http.BaseResponse;
import com.konne.nightmare.FastPublicOpinion.bean.OpinionDataBean;
import com.konne.nightmare.FastPublicOpinion.http.RetrofitFactory;
import com.konne.nightmare.FastPublicOpinion.mvp.model.IHomeFragmentModel;

import java.util.List;


public class HomeFragmentModelImpl implements IHomeFragmentModel {


    @Override
    public void myWarning(int pageNum, int pageSize, OnLoadDataListener<List<HomeBean.RowsBean>> onLoadDataListener) {
        RetrofitFactory.getInstance().myWarning(pageNum,pageSize, new BaseObserver<List<HomeBean.RowsBean>>() {
            @Override
            protected void onSuccess(BaseResponse<List<HomeBean.RowsBean>> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionList(int pageNum, int pageSize, String requestBody, OnLoadDataListener<List<OpinionDataBean.ResponseDataBean>> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionList(pageNum, pageSize, requestBody, new BaseObserver<List<OpinionDataBean.ResponseDataBean>>() {
            @Override
            protected void onSuccess(BaseResponse<List<OpinionDataBean.ResponseDataBean>> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionAddCollect(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionAddCollect(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionCancelCollect(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionCancelCollect(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionAddWarning(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionAddWarning(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionCancelWarning(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionCancelWarning(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionAddBriefing(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionAddBriefing(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionCancelBriefing(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionCancelBriefing(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionDataStatistics(String requestBody, OnLoadDataListener<OpinionDataBean.ResponseStatisticalDataBean> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionDataStatistics(requestBody, new BaseObserver<OpinionDataBean.ResponseStatisticalDataBean>() {
            @Override
            protected void onSuccess(BaseResponse<OpinionDataBean.ResponseStatisticalDataBean> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }

    @Override
    public void postOpinionDelete(String requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().postOpinionDelete(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }
}
